/*
 * 
 *
 *
 */
package com.hboxs.asl.dao.impl;

import com.hboxs.asl.dao.RushDao;
import com.hboxs.asl.entity.Rush;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Dao - 限时抢购
 */
@Repository("rushDaoImpl")
public class RushDaoImpl extends BaseDaoImpl<Rush, Long> implements RushDao {

    @Override
    public List<Rush> findEnableList() {
        String queryStr = "SELECT rush FROM Rush AS rush " +
                "WHERE rush.enable=true " +
                " AND " +
                "((current_timestamp between rush.beginDate AND rush.endDate) " +
                " OR " +
                " (current_timestamp >rush.createDate) )";
        return entityManager.createQuery(queryStr).getResultList();

    }
}
